<template>
  <view class="content flex ft28">
    <view class="scroller flex1 dlc-bg">
      <view
        class="box mg16-x mgt16 bgw pd30"
        v-for="item in list"
        :key="item.equipmentId"
        @tap="toNavigation(item.latitude,item.longitude)"
      >
        <view class="flex pd6-y">
          <view class="ft34 mgr20">设备编号</view>
          <view class="ft30 dlc-gray">{{item.equipmentNumber}}</view>
        </view>
        <view class="flex pd6-y">
          <view class="ft34 mgr20">设备地址</view>
          <view class="ft30 dlc-gray">{{item.province+item.area+item.city+item.equipmentAddress}}</view>
        </view>

        <view class="flex pd6-y">
          <view class="ft34 mgr20">距离</view>
          <view class="ft30 dlc-gray">{{item.distance/1000}}千米</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { getAroundList } from '@/api';
export default {
  data () {
    return {
      list: [
          // {
          //   "equipmentId":1,
          //   "distance": 0.0,
          //   "latitude": "22.555259",
          //   "equipmentNumber": "1023456",
          //   "longitude": "113.884020"
          // }
      ],
      location: {
        latitude: "",
        longitude: "",
      },
    }
  },
  methods: {
    // 导航
    toNavigation (latitude1,longitude1) {
      uni.openLocation({
        latitude: Number(latitude1),
        longitude: Number(longitude1),
        success: function (e) {
         
        },
        fail: function(e){
        
        }
      });
    },
    // 获取当前定位
    getPosition () {

    },
    // 获取附近设备列表
    async getList () {
      //调用服务器接口
      const { data } = await getAroundList({
        longitude: this.location.longitude,
        latitude: this.location.latitude
      })
      if (data.code === 1) {
        this.list = data.data
      }
    }
  },
  onLoad(option){
   this.location=option
   this.getList()
  },
  onShow () {
   
  }
}
</script>
<style lang="stylus" scoped>
  .scroller
    min-height 100vh
  .box  
    background #fff url('~@/assets/point.png') no-repeat 96%
    background-size 70upx 
</style>
